import { defHttp } from "/@/utils/http/axios";
import { LessonPlanModel } from "/@/api/model/practicalModel";
import { PageParams, PageResult, PageWithId } from "/@/api/model/pageModel";

enum Api {
  GetLessonPlanPage = "/lessonPlan/page",
  SaveLessonPlan = "/lessonPlan/save",
  UpdateLessonPlan = "/lessonPlan/update",
  RemoveLessonPlan = "/lessonPlan/remove",
  SetLessonPlanRemark = "/lessonPlan/setRemark",
}

export const getLessonPlanPageApi = (params: PageParams) =>
  defHttp.get<PageResult<LessonPlanModel>>({ url: Api.GetLessonPlanPage, params });

export const getLessonPlanPageByIdApi = (params: PageWithId) =>
  defHttp.get<PageResult<LessonPlanModel>>({
    url: `${Api.GetLessonPlanPage}/${params.userId}`,
    params,
  });

export const saveLessonPlanApi = (params: LessonPlanModel) =>
  defHttp.post({ url: Api.SaveLessonPlan, params });

export const updateLessonPlanApi = (params: LessonPlanModel) =>
  defHttp.put({ url: Api.UpdateLessonPlan, params });

export const removeLessonPlanApi = (planId: number) =>
  defHttp.delete({ url: Api.RemoveLessonPlan + `/${planId}` });

export const setLessonPlanRemarkApi = (userId: number, planId: number, content: string) =>
  defHttp.put({ url: Api.SetLessonPlanRemark + `/${userId}/${planId}`, params: { content } });
